::@echo OFF
:: Set this to 0 if you really don't want to use XP computers. If you set this to false, you don't need to run as administrator the first time
set MIXED=1
:: Change this to the path you want to use as the shared place for your picasa database. Typically a mapped folder (eg. E:\) on a NAS or in a public folder on a PC.
set PICASAPROFILEPATH=C:\PicasaProfileShared
:: Change this to the place where the picasa3.exe file can be found (normally only to change on 64bit computers)

set PICASAEXECPATH=C:\Program Files\Google\Picasa3\
:: This is only used in mixed-mode on Windows Vista or 7 computers... I would leave it as it is...
set PICASAPROFILEPATHMIXEDLOCAL=C:\PicasaProfile
:: Now the real script starts... normally you shouldn't change anything here...
:: Check if on windows XP
ver | find "XP" > nul
if %ERRORLEVEL% == 0 GOTO init_windows_xp
:: Else, if mixed is true: init mixed_mode way, otherwise just normal way...
IF %MIXED% == 1 GOTO init_windows_7_Vista_mixed
GOTO init_windows_7_Vista
:: Try to create the directory needed for Windows Vista or 7 (without support for XP!!!), otherwise he uses the default USERPROFILE anyway...
:init_windows_7_Vista
echo Starting in Windows Vista or Windows 7 only mode

set TEMPPATH="%PICASAPROFILEPATH%\Appdata\Local"
IF NOT EXIST %TEMPPATH% mkdir %TEMPPATH%
IF NOT EXIST %TEMPPATH% GOTO NoValidPath
set USERPROFILE=%PICASAPROFILEPATH%
GOTO run_picasa
:: If on Windows XP, try to create the directory needed for Windows XP, otherwise he uses the default USERPROFILE anyway...
:init_windows_xp
echo Starting in Windows XP mode

set TEMPPATH="%PICASAPROFILEPATH%\Local Settings\Application Data"
IF NOT EXIST %TEMPPATH% mkdir %TEMPPATH%
IF NOT EXIST %TEMPPATH% GOTO NoValidPath
set USERPROFILE=%PICASAPROFILEPATH%
GOTO run_picasa
:: Try to create the directories needed for Windows Vista or 7 (with support for XP!!!), otherwise he uses the default USERPROFILE anyway...
:init_windows_7_VISTA_mixed
echo Starting in Mixed mode on a Windows Vista or Windows 7 computer

set TEMPPATH="%PICASAPROFILEPATH%\Local Settings\Application Data"
IF NOT EXIST %TEMPPATH% mkdir %TEMPPATH%
IF NOT EXIST %TEMPPATH% GOTO NoValidPath
set TEMPPATH="%PICASAPROFILEPATHMIXEDLOCAL%\Appdata"

IF NOT EXIST %TEMPPATH% mkdir %TEMPPATH%
set TEMPPATH="%PICASAPROFILEPATHMIXEDLOCAL%\Appdata\Local"
IF NOT EXIST %TEMPPATH% mklink /D %TEMPPATH% "%PICASAPROFILEPATH%\Local Settings\Application Data"
IF NOT EXIST %TEMPPATH% GOTO NoValidPath
set USERPROFILE=%PICASAPROFILEPATHMIXEDLOCAL%
GOTO run_picasa
:: After the initialisations, continue to run picasa...
:run_picasa
:: Check if picasa is started already somewhere...
 and if not, create lockfile
set LOCKFILE="%PICASAPROFILEPATH%\PicasaRunning.txt"
IF EXIST %LOCKFILE% GOTO PicasaRunningAlready
echo Picasa was started by %USERNAME% at %date% %time% on computer %COMPUTERNAME% > %LOCKFILE%
 

:: Start Picasa...
echo This window just needs to keep standing here as long as you are working with picasa... once you close picasa, it will close as well...
echo.
echo You are running picasa with the picasa database located in %PICASAPROFILEPATH%
set TEMPPATH="%PICASAEXECPATH%"
IF NOT EXIST %TEMPPATH% GOTO NoValidPath
cd %TEMPPATH%
picasa3.exe
del %LOCKFILE%
GOTO EOF
:: If the path doesn't exist/couldn't be created... error
:NoValidPath
echo ERROR: the following path isn't available and/or couldn't be created: %TEMPPATH%
echo.
echo Mind: if you are running in the mode to be able to mix XP and Vista/7, you need to run this file the first time as an administrator!
echo.
pause 
GOTO EOF